package sb.constraint.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sb.constraint.demo.dto.Test1ReqDTO;

/**
 * @author zss
 * @date 2021/9/2 15:42
 * @Email:451682479@qq.com
 */
@Api(value = "API", tags = "Tag1")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation(value = "test1 XXX", notes = "xxxxxxxxxyyyy")
    @PostMapping("/test1")
    public String test1(@RequestBody @Valid Test1ReqDTO request) {

        return request.getAge().toString();
    }


    @PostMapping("/test2")
    public String test2(@RequestBody @Validated Test1ReqDTO request) {

        return request.getAge().toString();
    }

    @PostMapping("/test3")
    public String test3(@Validated Test1ReqDTO request) {

        return request.getAge().toString();
    }
}
